public class Main {
    public static int getElement(int[] arr,int index){
        if(arr==null)
            throw new NullPointerException("传递的数组为空");
        if(index<0||index>=arr.length)
            throw new ArrayIndexOutOfBoundsException("传递的数组下标越界");
        return arr[index];
    }
    public static void main(String[] args) {
      int[] arr={1,2,3,4,5};
        //System.out.println(getElement(null, 0));
        System.out.println(getElement(arr, 5));
    }
}